/*
 * Copyright 2025 Nimtable
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// This file is auto-generated by @hey-api/openapi-ts

import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
import type { LoginData, LoginResponse2, LoginError, LogoutData, LogoutResponse2, LogoutError, ResetPasswordData, ResetPasswordResponse, ResetPasswordError, GetCurrentUserProfileData, GetCurrentUserProfileResponse, GetCurrentUserProfileError, UpdateCurrentUserProfileData, UpdateCurrentUserProfileResponse, UpdateCurrentUserProfileError, GetUsersData, GetUsersResponse, GetUsersError, CreateUserData, CreateUserResponse, CreateUserError, DeleteUserData, DeleteUserResponse, DeleteUserError, GetUserByIdData, GetUserByIdResponse, GetUserByIdError, UpdateUserData, UpdateUserResponse, UpdateUserError } from './types.gen';
import { client as _heyApiClient } from './client.gen';

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
    /**
     * You can provide a client instance returned by `createClient()` instead of
     * individual options. This might be also useful if you want to implement a
     * custom client.
     */
    client?: Client;
    /**
     * You can pass arbitrary values through the `meta` object. This can be
     * used to access values that aren't defined as part of the SDK function.
     */
    meta?: Record<string, unknown>;
};

/**
 * User login
 * Authenticate user with username and password
 */
export const login = <ThrowOnError extends boolean = false>(options: Options<LoginData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).post<LoginResponse2, LoginError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/auth/login',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options?.headers
        }
    });
};

/**
 * User logout
 * Logout the current user and clear authentication token
 */
export const logout = <ThrowOnError extends boolean = false>(options?: Options<LogoutData, ThrowOnError>) => {
    return (options?.client ?? _heyApiClient).post<LogoutResponse2, LogoutError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/auth/logout',
        ...options
    });
};

/**
 * Reset user password
 * Update the current user's password
 */
export const resetPassword = <ThrowOnError extends boolean = false>(options: Options<ResetPasswordData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).patch<ResetPasswordResponse, ResetPasswordError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/auth/reset-password',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options?.headers
        }
    });
};

/**
 * Get current user profile
 * Returns the current authenticated user's profile information
 */
export const getCurrentUserProfile = <ThrowOnError extends boolean = false>(options?: Options<GetCurrentUserProfileData, ThrowOnError>) => {
    return (options?.client ?? _heyApiClient).get<GetCurrentUserProfileResponse, GetCurrentUserProfileError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/user-info',
        ...options
    });
};

/**
 * Update current user profile
 * Updates the current authenticated user's profile information
 */
export const updateCurrentUserProfile = <ThrowOnError extends boolean = false>(options: Options<UpdateCurrentUserProfileData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).patch<UpdateCurrentUserProfileResponse, UpdateCurrentUserProfileError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/user-info',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options?.headers
        }
    });
};

/**
 * Get all users
 * Returns a list of all users
 */
export const getUsers = <ThrowOnError extends boolean = false>(options?: Options<GetUsersData, ThrowOnError>) => {
    return (options?.client ?? _heyApiClient).get<GetUsersResponse, GetUsersError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/users',
        ...options
    });
};

/**
 * Create new user
 * Creates a new user
 */
export const createUser = <ThrowOnError extends boolean = false>(options: Options<CreateUserData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).post<CreateUserResponse, CreateUserError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/users',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options?.headers
        }
    });
};

/**
 * Delete user
 * Deletes a specific user
 */
export const deleteUser = <ThrowOnError extends boolean = false>(options: Options<DeleteUserData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).delete<DeleteUserResponse, DeleteUserError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/users/{userId}',
        ...options
    });
};

/**
 * Get user by ID
 * Returns a specific user by their ID
 */
export const getUserById = <ThrowOnError extends boolean = false>(options: Options<GetUserByIdData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).get<GetUserByIdResponse, GetUserByIdError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/users/{userId}',
        ...options
    });
};

/**
 * Update user role
 * Updates a specific user's role. Only admin and superadmin users can modify roles. Users cannot modify their own role.
 */
export const updateUser = <ThrowOnError extends boolean = false>(options: Options<UpdateUserData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).put<UpdateUserResponse, UpdateUserError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/acc-api/users/{userId}',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options?.headers
        }
    });
};